#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>

int main(int argc, char* argv[], char* env[])
{
    printf("original:\n");
    printf("%s=%s\n", "TEST1", getenv("TEST1"));
    printf("%s=%s\n", "TEST2", getenv("TEST2"));
    printf("%s=%s\n", "TEST3", getenv("TEST3"));

    putenv("TEST1"); // 清空TEST1的环境变量值
    putenv("TEST2=NEW-VALUE");
    putenv("TEST3=CREATE NEW");

    printf("new:\n");
    printf("%s=%s\n", "TEST1", getenv("TEST1"));
    printf("%s=%s\n", "TEST2", getenv("TEST2"));
    printf("%s=%s\n", "TEST3", getenv("TEST3"));

    int i = 0;
    extern char** environ;
    printf("changed:\n");
    while (environ[i]) {
        printf("exec = %d, %s\n", getpid(), environ[i++]);
    }

    return 0;
}
